/*     */ package com.zimbra.cs.account.soap;
/*     */ 
/*     */ import com.google.common.collect.Sets;
/*     */ import com.zimbra.common.account.Key.DistributionListBy;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.AdminConstants;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.soap.Element.XMLElement;
/*     */ import com.zimbra.cs.account.DynamicGroup;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.soap.admin.type.Attr;
/*     */ import com.zimbra.soap.admin.type.DLInfo;
/*     */ import com.zimbra.soap.admin.type.DistributionListInfo;
/*     */ import com.zimbra.soap.admin.type.DistributionListMembershipInfo;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class SoapDynamicGroup
/*     */   extends DynamicGroup
/*     */   implements SoapEntry
/*     */ {
/*     */   List<String> membersList;
/*     */   
/*     */   SoapDynamicGroup(String name, String id, Map<String, Object> attrs, Provisioning prov)
/*     */   {
/*  43 */     super(name, id, attrs, prov);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   SoapDynamicGroup(DistributionListMembershipInfo dlInfo, Provisioning prov)
/*     */     throws ServiceException
/*     */   {
/*  55 */     super(dlInfo.getName(), dlInfo.getId(), new HashMap(), prov);
/*     */     
/*     */ 
/*  58 */     addDlm(new ArrayList(), getRawAttrs());
/*     */   }
/*     */   
/*     */   SoapDynamicGroup(DistributionListInfo dlInfo, Provisioning prov) throws ServiceException
/*     */   {
/*  63 */     super(dlInfo.getName(), dlInfo.getId(), Attr.collectionToMap(dlInfo.getAttrList()), prov);
/*     */     
/*  65 */     addDlm(dlInfo.getMembers(), getRawAttrs());
/*     */   }
/*     */   
/*     */   SoapDynamicGroup(DLInfo dlInfo, Provisioning prov) throws ServiceException
/*     */   {
/*  70 */     super(dlInfo.getName(), dlInfo.getId(), Attr.collectionToMap(dlInfo.getAttrList()), prov);
/*     */     
/*     */ 
/*  73 */     addDlm(new ArrayList(), getRawAttrs());
/*     */   }
/*     */   
/*     */   SoapDynamicGroup(Element e, Provisioning prov) throws ServiceException {
/*  77 */     super(e.getAttribute("name"), e.getAttribute("id"), SoapProvisioning.getAttrs(e), prov);
/*  78 */     addDlm(e, getRawAttrs());
/*     */   }
/*     */   
/*     */   public String[] getAllMembers() throws ServiceException
/*     */   {
/*  83 */     if (this.membersList == null) {
/*  84 */       return new String[0];
/*     */     }
/*  86 */     return (String[])this.membersList.toArray(new String[this.membersList.size()]);
/*     */   }
/*     */   
/*     */   public Set<String> getAllMembersSet()
/*     */     throws ServiceException
/*     */   {
/*  92 */     if (this.membersList == null) {
/*  93 */       return Sets.newHashSet();
/*     */     }
/*  95 */     return Sets.newHashSet(this.membersList);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   private void addDlm(List<String> members, Map<String, Object> attrs)
/*     */   {
/* 104 */     setMembers(members);
/*     */   }
/*     */   
/*     */   private void setMembers(List<String> members) {
/* 108 */     this.membersList = members;
/*     */   }
/*     */   
/*     */   private void addDlm(Element e, Map<String, Object> attrs) {
/* 112 */     ArrayList<String> list = new ArrayList();
/* 113 */     for (Element dlm : e.listElements("dlm")) {
/* 114 */       list.add(dlm.getText());
/*     */     }
/* 116 */     addDlm(list, attrs);
/*     */   }
/*     */   
/*     */   public void modifyAttrs(SoapProvisioning prov, Map<String, ? extends Object> attrs, boolean checkImmutable) throws ServiceException {
/* 120 */     Element.XMLElement req = new Element.XMLElement(AdminConstants.MODIFY_DISTRIBUTION_LIST_REQUEST);
/* 121 */     req.addElement("id").setText(getId());
/* 122 */     SoapProvisioning.addAttrElements(req, attrs);
/* 123 */     Element dl = prov.invoke(req).getElement("dl");
/* 124 */     Map<String, Object> newAttrs = SoapProvisioning.getAttrs(dl);
/* 125 */     addDlm(dl, newAttrs);
/* 126 */     setAttrs(newAttrs);
/*     */   }
/*     */   
/*     */   public void reload(SoapProvisioning prov) throws ServiceException {
/* 130 */     Element.XMLElement req = new Element.XMLElement(AdminConstants.GET_DISTRIBUTION_LIST_REQUEST);
/* 131 */     Element a = req.addElement("dl");
/* 132 */     a.setText(getId());
/* 133 */     a.addAttribute("by", Key.DistributionListBy.id.name());
/* 134 */     Element dl = prov.invoke(req).getElement("dl");
/* 135 */     Map<String, Object> attrs = SoapProvisioning.getAttrs(dl);
/* 136 */     addDlm(dl, attrs);
/* 137 */     setAttrs(attrs);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/soap/SoapDynamicGroup.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */